<template>
  <i
    class="uafont"
    :class="`ua-${name}`"
    :style="{ fontSize, cursor, color: fontColor }"
  ></i>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

export default defineComponent({
  name: 'UIconfont',
  props: {
    name: String,
    size: Number,
    color: String,
    cursor: {
      type: String,
      values: ['', 'pointer', 'not-allowed'],
      default: '',
    },
  },
  data() {
    return {
      colorMap: {
        success: '#67C23A',
        waring: '#E6A23C',
        error: '#F56C6C',
        danger: '#F56C6C',
        info: '#909399',
      } as Record<string, string>,
    }
  },
  computed: {
    fontSize() {
      return `${this.size}${import.meta.env.VITE_LENGTH_UNIT}`
    },
    fontColor() {
      if (!this.color && this.name) {
        return this.colorMap[this.name] ?? ''
      }
      return ''
    },
  },
})
</script>

<style>
@import url('//at.alicdn.com/t/font_2901574_cdea89veqtc.css');
</style>
